#include <iostream>
#include <cstring>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
const int N=1e3+10;
const int M=2*1e4+10;

int n,m,s;
int dist[N];
int vis[N];
struct node{
	int b,w;
};

struct cmp{
	bool operator()(struct node& p1,struct node& p2)
	{
		return p1.w>p2.w;
	}
};

void dijkstra(int x,vector<node> edge[])
{
	memset(vis,0,sizeof(vis));
	memset(dist,0x3f3f3f3f,sizeof(dist));
	dist[x]=0;
	priority_queue<node,vector<node>,cmp> q;
	q.push({x,0});
	while(q.size())
	{
		int r=q.top().b;
		q.pop();
		if(vis[r])
			continue;
		vis[r]=1;
		for(auto& e:edge[r])
		{
			int aim=e.b;
			if(dist[aim]>dist[r]+e.w)
			{
				dist[aim]=dist[r]+e.w;
				q.push({aim,dist[aim]});
			}
		}
	}
}
int main()
{
	while(cin>>n>>m>>s)
	{
		vector<node> edge[N];
		for(int i=0;i<m;i++)
		{
			int p,q,t;
			cin>>p>>q>>t;
			edge[p].push_back({q,t});
		}
		int k;
		cin>>k;
		while(k--)
		{
			int t;
			cin>>t;
			edge[0].push_back({t,0});
		}
		dijkstra(0,edge);
		if(dist[s]==0x3f3f3f3f)
			cout<<-1<<endl;
		else
			cout<<dist[s]<<endl;
		
	}
	
	
	return 0;
}
